package top.songxs.gmall.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import top.songxs.gmall.common.result.Result;
import top.songxs.gmall.feign.order.OrderFeignClient;
import top.songxs.gmall.order.vo.OrderConfirmVo;

@Controller
public class OrderController {
    @Autowired
    private OrderFeignClient orderFeignClient;

    @GetMapping(value = "/trade.html")
    public String toTrade(Model model) {
        Result<OrderConfirmVo> resultVo = orderFeignClient.orderConfirmData();
        OrderConfirmVo confirmVo = resultVo.getData();

        // 从OrderConfirmVo中获取购物车数据，将其存储到Model对象中
        model.addAttribute("detailArrayList" , confirmVo.getDetailArrayList()) ;
        model.addAttribute("totalNum" , confirmVo.getTotalNum()) ;
        model.addAttribute("totalAmount" , confirmVo.getTotalAmount()) ;
        model.addAttribute("userAddressList" , confirmVo.getUserAddressList()) ;
        model.addAttribute("tradeNo" , confirmVo.getTradeNo()) ;
        return "order/trade";
    }
    @GetMapping(value = "myOrder.html")
    public String toOrderList(){
        return "order/myOrder";
    }
}
